#include <iostream>
#include <map>
#include <string>
#include <cmath>
#include <string.h>

using namespace std;

#define eps 1E-9

double A[200][200];
double week[50];
int job[200];
map<string, int> name;
int totalJobs, totalWeeks;

int main()
{
	int nlines;
	while (cin >> nlines)
	{
		name.clear();
		totalJobs = 0;
		totalWeeks = 0;

		string s;
		int hours;

		memset(A, 0, sizeof(A));

		while (0 < nlines--)
		{
			cin >> s >> hours;
			if (s == ".")
			{
				week[totalWeeks] = hours;
				totalWeeks++;
			}
			else
				if (name.find(s) == name.end())
				{
					name[s] = totalJobs;
					A[totalWeeks][totalJobs] = hours;
					totalJobs++;
				}
				else
				{
					A[totalWeeks][name[s]] = hours;
				}
		}

		for (int i = 0; i < totalWeeks; i++) 
		{
			for (int j = 0; j < totalJobs; j++) 
			{
				cout << A[i][j] << " ";
			}
			cout << week[i] << endl;

			cout << endl;
		}

		if (totalWeeks < totalJobs) cout << "Incomplete data\n.\n";
		else
		{
			for (int j = 0; j < totalJobs; j++)
			{
				int l = -1;
				for (int i = 0; i < totalWeeks; i++) 				
					if (abs(A[i][j]) > eps)
					{
						l = i;
						break;
					}

				for (int i = 0; i < totalWeeks; i++) 
					if (abs(A[i][j]) > eps && (i != l))
					{
						double ratio = A[i][j]/A[l][j];
						for (int k = j; k < totalJobs; k++) A[i][k] = A[i][k] - ratio * A[l][k];
						week[i] = week[i] - ratio * week[l];
					}

			for (int i = 0; i < totalWeeks; i++) 
			{
				for (int j = 0; j < totalJobs; j++) 
				{
					cout << A[i][j] << " ";
				}
				cout << week[i];
				cout << endl;
			}

			}

			for (int i = 0; i < totalWeeks; i++) 
			{
				for (int j = 0; j < totalJobs; j++) 
				{
					cout << A[i][j] << " ";
				}
				cout << week[i];
				cout << endl;
			}

			// either inconsistent or ...
		}
	}
	
	return 0;
}
